#! /bin/sh

case "$1" in
  upgrade)
    #
  ;;
  *)
    if [ -f /.dockerenv ]; then exit 0; fi
    echo "Stopping pf_ring.."
    if hash systemctl 2>/dev/null; then
      if hash deb-systemd-invoke 2>/dev/null; then
        deb-systemd-invoke stop pf_ring
        deb-systemd-invoke disable pf_ring > /dev/null
        deb-systemd-invoke stop cluster
        deb-systemd-invoke disable cluster > /dev/null
      else
        /bin/systemctl stop pf_ring
        /bin/systemctl disable pf_ring > /dev/null
        /bin/systemctl stop cluster
        /bin/systemctl disable cluster > /dev/null
      fi
      /bin/systemctl stop 'cluster@*' --all
      /bin/systemctl disable 'cluster@' --all > /dev/null
      /bin/systemctl daemon-reload
      /bin/systemctl reset-failed
    else
      /etc/init.d/pf_ring stop
      /etc/init.d/cluster stop
    fi
  ;;
esac

exit 0
